package com.ycz;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * @author ycz
 * @date 2021/6/18
 */
@Configuration
public class Applicatioin {

    @Bean
    public UserFactoryBean userFactoryBean(){
        return new UserFactoryBean();
    }

    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
        applicationContext.register(Applicatioin.class);
        applicationContext.refresh();
        // 通过userFactoryBean代理创建userMapper bean
        UserMapper userMapper = applicationContext.getBean("userFactoryBean", UserMapper.class);
        userMapper.getById();
        userMapper.getByName();

    }


}
